#!/usr/bin/python
# vim: set fileencoding=utf-8:  
import sys

#设置你自己的163用户名和密码
username = 'yeaxxx@163.com'
password = 'lsb450321'

# Import smtplib for the actual sending function
import smtplib
def mail_to_qq(qq_mail,title, content):
    # Import the email modules we'll need
    from email.mime.text import MIMEText
    msg = MIMEText(content,'html','utf8') #这是正确显示Html中文的设置，会解析html标签，不再是原始文本。
    msg.set_charset('utf8')#这是正确显示中文的设置
    msg['Subject'] = title
    msg['From'] = username 
    msg['To'] = qq_mail
    # Send the message via our own SMTP server, but don't include the
    # envelope header.
    s = smtplib.SMTP('smtp.163.com')
    s.login(username, password)
    s.sendmail(username , [qq_mail], msg.as_string())
    s.quit()

